﻿using Microsoft.Graphics.Canvas;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;
using 纸片人.AttributeUsageFloder;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板

namespace 纸片人.PageViews
{
    [LastModified("2022-5-12", "create PolarPlaneCoor.xaml")]
    [PageType("cpu", "极坐标")]
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class PolarPlaneCoor : Page
    {

        int width, height;
        Color[] colors, tempColors;
        WriteableBitmap wb;

        double r, a, b,m;

        private void circleFilter_Click(object sender, RoutedEventArgs e)
        {
           
                tempColors = PictureFilter.SectorGraphicsEffect(colors, width, height,0);

        


            Function.InitialImage(tempColors, width, height, image1);
        }

        private void coorPlanePolar_Click(object sender, RoutedEventArgs e)
        {

           

            tempColors = PictureFilter.CoorPlanePolarEffect(colors, width, height);


            Function.InitialImage(tempColors, width, height, image1);
        }

        int cx, cy;

        private void polarPlaneCoorr_Click(object sender, RoutedEventArgs e)
        {


            

           tempColors =  PictureFilter.PolarPlaneCoorrEffect(colors, width, height);

            Function.InitialImage(tempColors, width, height, image1);

        }

  

        public PolarPlaneCoor()
        {
            this.InitializeComponent();
        }

        private async void selectImage_Click(object sender, RoutedEventArgs e)
        {
           CanvasBitmap bitmap =await Function.SelectImageAsync();
            Function.InitialParameter(bitmap, out width, out height, out colors, out tempColors, image, out wb);
            cx = (width+1) / 2;
            cy =(1+ height) / 2;
            r = height / 2;
            a = width / 2;
            b = height / 2;
            m = width / height;
        }
    }
}
